import { LoginAction } from '@/interface/store/reducers';
import { Token } from '@/interface/token';
import { getToken } from '@/utils/token';

const initValue: Token = {
    token: getToken().token || '',
};
const login = (prevState = initValue, action: LoginAction) => {
    switch (action.type) {
        case 'login/getToken':
            return action.payload;
        case 'logout/removeToken':
            return action.payload;
        default:
            return prevState;
    }
};

export default login;
